<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>javascript 阶段</title>
    <style>
        ul {
            list-style: none;
            padding: 0;
            margin: 0;
            width: 450px;
        }
        ul li {
            width: 450px;
            height: 50px;
            /* border-bottom: 1px solid #000; */
            margin-top: 10px;
            /* 弹性布局 */
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        ul li .left {
            width: 260px;
            height: 40px;
            line-height: 40px;
            border: 1px solid #000;
            text-align: center;
            font-size: 30px;
            background-color: orange;
        }
        ul li .right button {
            background-color: transparent;
            border: 1px solid #ccc;
            width: 140px;
            height: 40px;
            border-radius: 10px;
            cursor: pointer;
            outline: none;
        }
    </style>
</head>
<body>
    <ul>
        <li>
            <div class="left">3楼</div>
            <div class="right"><button data-index="0">按钮</button></div>
        </li>

        <li>
            <div class="left">2楼</div>
            <div class="right"><button data-index="1">按钮</button></div>
        </li>


        <li>
            <div class="left">1楼</div>
            <div class="right"><button  data-index="2">按钮</button></div>
        </li>



    </ul>

    <script>
        // 步骤：
            // 1.0 获取页面相关元素
            // 2.0 进行事件的绑定
            // 3.0 书写程序的处理逻辑


        // 编码：
            // 1.0 获取页面相关元素
            // 左边标签数组
            var leftItems = document.querySelectorAll(".left");
            // 右侧按钮数组
            var buttonItems = document.querySelectorAll(".right button");
        
            // 2.0 进行事件的绑定
            buttonItems[0].onclick = function(){
                  // 3.0 书写程序的处理逻辑
                  buttonItems[0].style.backgroundColor = "#ccc";
                  leftItems[0].style.backgroundColor = "#ccc";
            }

            buttonItems[1].onclick = function(){
                  // 3.0 书写程序的处理逻辑
                  buttonItems[1].style.backgroundColor = "#ccc";
                  leftItems[1].style.backgroundColor = "#ccc";
            }


            buttonItems[2].onclick = function(){
                  // 3.0 书写程序的处理逻辑
                  buttonItems[2].style.backgroundColor = "#ccc";
                  leftItems[2].style.backgroundColor = "#ccc";
            }




          








    </script>
</body>
</html>